package edu.nf.exam.service.impl;

import com.github.pagehelper.PageInfo;
import edu.nf.exam.dao.TaskInfoDao;
import edu.nf.exam.dao.impl.TaskInfoDaoImpl;
import edu.nf.exam.entity.TaskInfo;
import edu.nf.exam.exception.DataAcessException;
import edu.nf.exam.service.TaskService;

import java.util.List;

/**
 * @Author : QYM
 * @create 2021/6/17
 * 任务信息表--业务接口实现类
 */
public class TaskServiceImpl implements TaskService {
    /**
     * 添加
     * @param taskInfo
     */
    @Override
    public void add(TaskInfo taskInfo) {
        TaskInfoDao dao=new TaskInfoDaoImpl();
        try {
            dao.add(taskInfo);
        } catch (Exception e) {
            e.printStackTrace();
            throw new DataAcessException("添加失败");
        }
    }

    /**
     * 分页查询
     * @param title
     * @param levelName
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<TaskInfo> listTask(String title, String levelName, Integer pageNum, Integer pageSize) {
        List<TaskInfo> list = new TaskInfoDaoImpl().listTask(title, levelName, pageNum, pageSize);
        PageInfo<TaskInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 根据年级查询
     * @param levelName
     * @return
     */
    @Override
    public List<TaskInfo> selectByLevel(String levelName) {
        List<TaskInfo> list = new TaskInfoDaoImpl().selectByLevel(levelName);
        return list;
    }

    /**
     * 多条件查询
     * @param taskInfo
     * @return
     */
    @Override
    public List<TaskInfo> select(TaskInfo taskInfo) {
        List<TaskInfo> list = new TaskInfoDaoImpl().select(taskInfo);
        return list;
    }
}
